package studyguide.ch12;

import javax.microedition.rms.RecordFilter;

public class PersonAgeFilter implements RecordFilter {

	private final int age;
	private final boolean greater;
	
	public PersonAgeFilter(int age, boolean greater) {
		this.age = age;
		this.greater = greater;
	}
	
	public boolean matches(byte[] candidate) {
		Person person = new Person(candidate);
		
		boolean result;
		
		if (person.getAge() >= age) {
			result = true;
		} else {
			result = false;
		}
		
		if (!greater) {
			result = ! result;
		}
		
		return result;
	}

}
